package com.hdoit.jiayuntong.activity;

import com.handmark.pulltorefresh.library.PullToRefreshWebView;
import com.hdoit.jiayuntong.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageButton;
import android.widget.TextView;
/**
 * 首页
 * @author truly
 *
 */
public class HomePageFragment extends Fragment {
     
	private View view;
	private PullToRefreshWebView mPullRefreshWebView;
	private WebView mWebView;
	
	
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		view = inflater.inflate(R.layout.activity_homepage_tab_fragment, null);

		TextView tv_title_text = (TextView)view.findViewById(R.id.tv_title_text);
		tv_title_text.setText("店铺名称");

		ImageButton ib_back = (ImageButton)view.findViewById(R.id.ib_back);
		ib_back.setVisibility(View.GONE);
		
		mPullRefreshWebView = (PullToRefreshWebView)view.findViewById(R.id.pull_refresh_webview);
		mWebView = mPullRefreshWebView.getRefreshableView();
		mWebView.getSettings().setJavaScriptEnabled(true);
		mWebView.setWebViewClient(new SampleWebViewClient());
		mWebView.loadUrl("http://www.baidu.com");
		return view;
	}
	
	private static class SampleWebViewClient extends WebViewClient {
		@Override
		public boolean shouldOverrideUrlLoading(WebView view, String url) {
			view.loadUrl(url);
			return true;
		}
	}
}
